package com.zy.thread.yield;

/**
 * @Author Gong
 * @Description
 * @dATE 2022/3/27 20:24
 **/
public class MyThread implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println(Thread.currentThread().
                    getName() + "正在运行：" + i);
            if (i == 3) {
                System.out.print("线程"+Thread.currentThread().
                        getName()+ "礼让：");
                Thread.yield();
            }
        }
    }
}